package com.sugou.dao.support.ext.beans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.sugou.dao.enums.ConditionsType;
import com.sugou.dao.support.ParamsStatement;
import com.sugou.dao.support.Statement;
import com.sugou.dao.support.ext.Conditions;

public class ConditionsImpl implements Conditions {
	private static final long serialVersionUID = -7203376076212390511L;

	private Statement body;
	
	private ConditionsType type;
	
	private List<Serializable> params;
	
	public ConditionsImpl(Statement body,List<Serializable> params,ConditionsType type) {
		this.body=body;
		this.params=params;
		this.type=type==null?ConditionsType.AND:type;
	}

	public List<? extends Serializable> getParams() {
		List<Serializable> tmp=new ArrayList<Serializable>();
		if(body instanceof ParamsStatement){
			tmp.addAll(((ParamsStatement) body).getParams());
		}
		tmp.addAll(this.params);
		return tmp;
	}

	public String getContent() {
		return this.body.getContent();
	}

	public Statement getBody() {
		return this.body;
	}

	public ConditionsType getType() {
		return type;
	}

}
